package com.skyhigh.web.webservice.persistence;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

import org.hibernate.type.Type;

public abstract class AbstractQuery implements Query{
	
	private String id;
	private String nature;
	private String statement;
	private Class mappingClass;
	private String mappingClassName;
	
    private List parameters;
    public static final int INTEGER = 0;
    public static final int STRING = 1;
	public static final int TIMESTAMP = 2;	

    public void addParam(Object value){
        if (parameters == null)
            parameters = new LinkedList();
        parameters.add(new Parameter(parameters.size(), TypeHelper.inferType(value), value));
    }
    
    public void addParam(int index, Object value){
        if (parameters == null)
            parameters = new LinkedList();
        parameters.add(new Parameter(index, TypeHelper.inferType(value), value));
    }
    
    public void addParam(int index, QueryTypes type, Object value) {
        if (parameters == null)
            parameters = new ArrayList();        
        Type hbType = TypeHelper.getEquivalent(type);        
        parameters.add(new Parameter(index, hbType, value));
    }

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getStatement() {
		return statement;
	}

	public void setStatement(String statement) {
		this.statement = statement;
	}

	public List getParameters() {
		return parameters;
	}

	public void setParameters(List parameters) {
		this.parameters = parameters;
	}

	public String getNature() {
		return nature;
	}

	public void setNature(String nature) {
		this.nature = nature;
	}

	public Class getMappingClass() {
		return mappingClass;
	}

	public void setMappingClass(Class mappingClass) {
		this.mappingClass = mappingClass;
	}

	public String getMappingClassName() {
		return mappingClassName;
	}

	public void setMappingClassName(String mappingClassName) {
		this.mappingClassName = mappingClassName;
	}


}
